Skip to content

ts(B-0086): port 2 scripts (.sh→.ts) — slice 11 of TS/Bun migration#884

Merged
AceHack merged 10 commits intomainfrom
lane-b/ts-bun-slice-11-dv2-frontmatter-backfill-2026-04-30
Apr 30, 2026
Merged

ts(B-0086): port 2 scripts (.sh→.ts) — slice 11 of TS/Bun migration#884
AceHack merged 10 commits intomainfrom
lane-b/ts-bun-slice-11-dv2-frontmatter-backfill-2026-04-30

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented Apr 30, 2026

Summary

  • Slice 11 of the TS+Bun migration. Ports 2 scripts: skill-catalog DV-2.0 backfill + NuGet packages audit.

Files

  • `tools/skill-catalog/backfill_dv2_frontmatter.{sh→ts}` — mechanical DV-2.0 frontmatter backfill
  • `tools/audit-packages.{sh→ts}` — NuGet feed audit per Directory.Packages.props

Plus RESUME.md + slice-audits.md updates.

Equivalence

  • `backfill_dv2_frontmatter`: byte-equivalent on `--dry-run` mode.
  • `audit-packages`: network-dependent; offline-mode produces '?' for all packages in both bash + TS.

Lint + types

Both files pass `bun x tsc --noEmit` + `bun x eslint` clean.

🤖 Generated with Claude Code

AceHack added 3 commits April 30, 2026 00:08
First script of slice 11. Mechanical DV-2.0 frontmatter backfill
for SKILL.md files. Computes 5 missing fields from git history
(record_source / load_datetime / last_updated / status /
bp_rules_cited) and injects before closing frontmatter fence.

Byte-equivalent against bash original on --dry-run mode.

Mechanical changes:
- bash awk frontmatter parse → fieldPresent + dashCount helpers
- bash compute_record_source heuristic (round-N regex + author-
  date fallback) preserved as computeRecordSource
- bash mktemp + awk inject + mv rename → readFileSync +
  injectBeforeSecondFence + writeFileSync
- bash 'INJECT_BLOB env-passing' awk pattern → in-memory string
  array
- bash --all glob (find -maxdepth 2) → readdirSync filter
- All output strings preserved verbatim

Lint-clean (eslint + sonarjs + tsc).
Second script of slice 11. Network-dependent NuGet feed audit:
checks every Directory.Packages.props PackageVersion entry
against `dotnet package search --exact-match`.

Mechanical changes:
- bash grep+sed extraction → PACKAGE_RE.exec loop yielding
  PackageEntry tuples
- bash awk pipe-table parse → cols.split('|').map(trim) + col2
  match check; preserves 'last matching row' semantics
- bash printf '%-35s %-15s ...' → pad helper
- 3 statuses preserved: ✓ up-to-date / ? couldn't query /
  ⚠ bump available
- Exit-code semantics preserved: 0 = all queryable on latest,
  1 = one or more bumps available

Network-dependent so byte-equivalence requires offline-mode
testing (both bash + TS produce '?' for all packages when
`dotnet package search` fails — verified locally).

Lint-clean (eslint + sonarjs + tsc).
- slice-audits.md: append slice-11 audit (2 ports — backfill_dv2_frontmatter
  + audit-packages).
- RESUME.md: bump slice-9 → slice-10-merged (#883, commit 271bc38).
  Milestone 31 → 33. Bucket B 14 → 12.
Copilot AI review requested due to automatic review settings April 30, 2026 04:10
@AceHack AceHack enabled auto-merge (squash) April 30, 2026 04:10
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts Fixed
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts Fixed
CodeQL flagged 2 file-system-race-condition findings on
backfill_dv2_frontmatter.ts where stat-then-read patterns
(statSync(path).isFile() followed by later readFileSync) could
race. Refactored to:

1. processOne: removed initial statSync gate; readFileSync
   directly with try/catch + ENOENT/EISDIR detection on the
   error.code property to map to warn/error outcomes. Preserves
   the original bash 'skip non-file' UX without the race window.
2. findAllSkillFiles: removed statSync probe of candidate paths;
   readdirSync only filters by directory entries; processOne
   handles missing/non-file paths gracefully via its try/catch.

Equivalence preserved: --dry-run output unchanged on a fresh
SKILL.md fixture.

Lint-clean (eslint + sonarjs + tsc).
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 744f173301

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/audit-packages.ts
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports two repository automation scripts from Bash to TypeScript/Bun as part of the ongoing TS/Bun migration trajectory (slice 11), plus updates the migration tracking docs.

Changes:

  • Add tools/skill-catalog/backfill_dv2_frontmatter.ts to mechanically backfill DV-2.0 frontmatter fields in SKILL.md files.
  • Add tools/audit-packages.ts to audit Directory.Packages.props pins against NuGet via dotnet package search.
  • Update TS/Bun migration trajectory docs to record slice 11 status.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
tools/skill-catalog/backfill_dv2_frontmatter.ts New Bun/TS implementation of DV-2.0 frontmatter backfill for skill catalog files.
tools/audit-packages.ts New Bun/TS implementation of NuGet package pin audit against latest available versions.
docs/trajectories/typescript-bun-migration/slice-audits.md Adds slice 11 audit entry describing the ports and equivalence notes.
docs/trajectories/typescript-bun-migration/RESUME.md Updates trajectory status/milestone to reflect slice 10 merged and slice 11 in-flight.

Comment thread tools/audit-packages.ts
Comment thread docs/trajectories/typescript-bun-migration/slice-audits.md Outdated
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Comment thread tools/audit-packages.ts
AceHack added 2 commits April 30, 2026 00:17
Codex flagged backfill_dv2_frontmatter.ts losing the bash
original's atomic-rewrite invariant: bash used `mktemp` + `mv`
so a crash/kill/disk-full mid-write leaves the source file
intact. The TS port's writeFileSync truncates in place — a
real regression vs bash.

Restored: write to sibling tmp file (`<path>.tmp.<pid>.<ts>`)
then renameSync to target. Same-filesystem rename is atomic
on POSIX. Cleanup on failure: unlink the tmp + return structured
error outcome (exitCode 2).
Three real fixes:
- backfill_dv2_frontmatter: chdir to repoRoot() before --all scan
  (was cwd-dependent; both bash + TS had the bug, TS fixes at the
  entry point) + restored full canonical script path in usage
  message to match emitHelp()
- slice-audits.md: corrected audit-packages.ts line count
  '51 → 154' to '51 → 143' (actual wc -l)

Three pushed back as intentional bash-equivalence:
- audit-packages stdout vs stderr — bash uses echo to stdout
- audit-packages exit-code 64 — bash uses 1
- backfill gitOutput silently returns empty — bash awk on empty
  input behaves identically (both produce empty injected values)

Atomic-rewrite duplicate finding (already addressed in 5baf773)
resolved as duplicate.
Copilot AI review requested due to automatic review settings April 30, 2026 04:19
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5baf773a27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/audit-packages.ts Outdated
…ex P2

Codex flagged that the audit-packages.ts repoRoot using
`git rev-parse --show-toplevel` with cwd fallback regresses
invocation semantics from the bash original
(`cd "$(dirname "$0")/.." && pwd`). Bash resolves the script
location and walks up; TS+git-rev-parse fails outside a git
checkout (falls back to wrong cwd).

Fixed: switch to `fileURLToPath(import.meta.url)` + `resolve`
to match bash's script-relative resolution. Now works from any
caller directory and outside git checkouts.
auto-merge was automatically disabled April 30, 2026 04:24

Pull Request is not mergeable

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Codex flagged renameSync(tmpPath, file) as a potential Windows
data-loss issue (older Node fs.rename refused to overwrite on
Windows). Modern Node/Bun renameSync DOES overwrite atomically
on all platforms, but edge cases (Windows file locks from open
editors, permission-restricted network shares) can still fail.

Added defense-in-depth fallback: catch the renameSync failure,
unlink the destination, then retry rename. Loses atomicity for
the failure window but recovers correctness. Bash 'mv' has the
same fragility — same UX as bash, just more robust.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfbd6dc1b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts Outdated
Comment thread tools/audit-packages.ts
…per Codex P1+P2

P1 backfill_dv2_frontmatter (preserve-original-on-failure):
Removed the unlink-before-retry fallback that risked deleting the
original SKILL.md without successfully writing the new content.
On rename failure, return error with tmp-preserved message; do
NOT touch the original. Modern Node/Bun renameSync handles the
common case atomically; rare failures (Windows file lock, perms,
disk-full) leave the original intact + tmp recoverable.

P2 audit-packages (fail-on-empty-parse):
If PACKAGE_RE.exec yields 0 entries on a non-empty
Directory.Packages.props, the regex has likely drifted from the
file format. Silent success hides this. Now returns exit 1 with
clear error pointing at the regex-drift suspicion.
Copilot AI review requested due to automatic review settings April 30, 2026 04:31
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread tools/skill-catalog/backfill_dv2_frontmatter.ts
Comment thread docs/trajectories/typescript-bun-migration/RESUME.md Outdated
Headline said '33 hygiene/lint/audit scripts ported' but the
parenthesized addends summed to 32 (including the 2 in-flight).
Two issues conflated:

1. 'ported' implies merged but the count included in-flight.
2. Off-by-one — 11 merged-PR contributions sum to 30, not 31.

Fixed: '30 ported + 2 in-flight = 32 total' with explicit
delineation between merged and in-flight.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@AceHack AceHack merged commit 9237756 into main Apr 30, 2026
33 of 35 checks passed
@AceHack AceHack deleted the lane-b/ts-bun-slice-11-dv2-frontmatter-backfill-2026-04-30 branch April 30, 2026 04:42
AceHack added a commit that referenced this pull request Apr 30, 2026
- slice-audits.md: append slice 12 audit (1 port — backlog/generate-index).
  Also flip slices 8/9/10/11 from "PR pending" to merged-with-PR-number.
- RESUME.md: bump slice-10-merged → slice-11-merged (#884, commit 9237756).
  Milestone 32 → 33 (32 ported + 1 in-flight). Bucket B 12 → 10. Update
  Bucket B remaining list (10 entries) and Bucket D ported list (now 32
  entries with slice-9/10/11 ports added).
AceHack added a commit that referenced this pull request Apr 30, 2026
…ation (#885)

* ts(slice-12, wip 1/N): port backlog/generate-index (.sh→.ts)

First script of slice 12. Regenerates docs/BACKLOG.md from per-row
files at docs/backlog/P<tier>/B-<NNNN>-<slug>.md. Walks the per-
row files, parses YAML frontmatter, emits a short-pointer index
sorted by (priority, id).

Byte-equivalent against bash original on --stdout mode.

Mechanical changes:
- bash awk frontmatter parser (state machine + gsub for quote-
  stripping) → extractField + stripQuotes helpers
- bash find -name 'B-*.md' -type f -print0 | sort -z → readdirSync
  filter + locale-sort by basename
- bash mktemp + atomic mv rename → readFileSync compare +
  conditional writeFileSync
- bash diff -q + diff invocation in --check mode → in-memory
  line-by-line comparison emitting < / > diff markers
- Phase-1a safety guard preserved: 50-line threshold + BACKLOG_WRITE_FORCE=1
  env override
- Three modes preserved: write (default) / --check / --stdout

Lint-clean (eslint + sonarjs + tsc).

* trajectory(ts-bun): slice 12 audit substrate + RESUME tracker

- slice-audits.md: append slice 12 audit (1 port — backlog/generate-index).
  Also flip slices 8/9/10/11 from "PR pending" to merged-with-PR-number.
- RESUME.md: bump slice-10-merged → slice-11-merged (#884, commit 9237756).
  Milestone 32 → 33 (32 ported + 1 in-flight). Bucket B 12 → 10. Update
  Bucket B remaining list (10 entries) and Bucket D ported list (now 32
  entries with slice-9/10/11 ports added).
AceHack added a commit that referenced this pull request Apr 30, 2026
AceHack added a commit that referenced this pull request Apr 30, 2026
…11 merged + slice-12 opened (#886)

* ops(tick-history): autonomous-loop tick 2026-04-30T04:46:00Z — slice-11 #884 merged + slice-12 #885 opened

* ops(tick-history): fix col-5 schema drift on row 318 per Copilot

Copilot caught two related findings on PR #886:

1. The PR description said "5 pipe-separated cells: timestamp/model/
   cron-id/main-text/observations" but the file's actual schema
   (line 17 of loop-tick-history.md) uses 6 columns:
   `date | agent | cron-id | action-summary | commit-or-link | notes`.

2. Row 318's column 5 contained descriptive prose
   (`(slice-11 merge + slice-12 PR-open consolidated row)`) instead
   of a commit SHA / em-dash / link as the schema requires.

Replaced col-5 with the slice-11 merge commit SHA `9237756` and
parenthetical pointer to slice-12's eventual merge commit `cfb5964`
(merged shortly after the row was written). Schema-conformant.

The PR-body 5-cell claim was a separate description error in the
PR body; this commit only fixes the file content. PR body will be
updated on push.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants